package com.tech.arno.spicy.mvp.presenterImpl;

import com.tech.arno.spicy.module.course.BaseCourseModel;
import com.tech.arno.spicy.mvp.presenter.CourseDetailPresenter;
import com.tech.arno.spicy.mvp.view.CourseDetailView;
import com.tech.arno.spicy.network.http.RequestCenter;
import com.tech.arno.spicysdk.okhttp.listener.DisposeDataListener;

/*
*   @package:     com.tech.arno.spicy.mvp.presenterImpl
*   @fileName:    CourseDetailPresenterImpl
*   @author:    ArnoFrost
*   @date:  2017/12/22 0022 8:33
*   @desc:     评论Presenter实现类
*/

public class CourseDetailPresenterImpl implements CourseDetailPresenter {
    private BaseCourseModel mData;
    private CourseDetailView courseDetailView;

    public CourseDetailPresenterImpl(CourseDetailView courseDetailView) {
        this.courseDetailView = courseDetailView;
    }

    @Override
    public void requestDeatil(String mCourseID) {

        RequestCenter.requestCourseDetail(mCourseID, new DisposeDataListener() {
            @Override
            public void onSuccess(Object responseObj) {
                mData = (BaseCourseModel) responseObj;
                if (courseDetailView != null) {
                    courseDetailView.updateUI(mData);
                }
            }

            @Override
            public void onFailure(Object reasonObj) {
                courseDetailView.onError();
            }
        });
    }


    @Override
    public void onDestroy() {
        courseDetailView = null;
    }
}
